package com.pignest.hotel.definition;

import java.util.ArrayList;
import java.util.List;

/**
 * 支付方式<br/>
 * */
public enum PayMethod {
	
	CASH("现金", 0),
	CREDIT_CARD("信用卡", 0),
	DEBIT_CARD("借记卡", 0),
	MEMBER_CARD("会员卡", 1),
	
	;
	
	private final String displayName;
	private final int type;
	
	PayMethod(String displayName, int type) {
		this.displayName = displayName;
		this.type = type;
	}
	
	public String getDisplayName() {
		return displayName;
	}
	
	public String getName() {
		return name();
	}
	
	public int getType() {
		return type;
	}
	
	public static PayMethod valueof(String name) {
		try {
			return PayMethod.valueOf(name);
		} catch (Exception e) {
		}
		return null;
	}
	
	public static String[][] getMethods(boolean all) {
		PayMethod[] methods = PayMethod.values();
		List<String[]> m = new ArrayList<String[]>();
		for (int i = 0; i < methods.length; i++) {
			if (all || methods[i].type == 0) {
				String[] a = new String[] {methods[i].name(), methods[i].displayName};
				m.add(a);
			}
		}
		return m.toArray(new String[2][methods.length]);
	}
	public static void main(String[] args){
		PayMethod[] methods = PayMethod.values();
		System.out.println(methods.length);
		String[][] pay= PayMethod.getMethods(false);
		System.out.println(pay.length);
		for(int i=0;i<pay.length;i++){
			System.out.println("pay["+i+"][0]"+pay[i][0]+",pay["+i+"][1]="+pay[i][1]);
			
		}
	}
	
	public boolean is(String name) {
		return name().equals(name);
	}
}
